<template>
    <div class="app-container" style="padding: 10px;">
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="销售订单参考" name="first">
                <el-card class="box-card">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">筛选条件</span>
                    </div> 
                    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="110px" label-position="top">
                        <el-form-item label="发货时间-起始" prop="fhDateStart">
                            <el-date-picker v-model="queryParams.fhDateStart" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="发货时间-结束" prop="fhDateEnd">
                            <el-date-picker v-model="queryParams.fhDateEnd" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="用友商品名称" prop="pname">
                            <el-input v-model="queryParams.pname"></el-input>
                        </el-form-item>
                        <el-form-item label="片区" prop="dpt">
                            <el-select v-model="queryParams.dpt" filterable>
                                <el-option v-for="item in depts" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="销售" prop="salename">
                            <el-select v-model="queryParams.salename" filterable>
                                <el-option v-for="item in sales" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="客户姓名" prop="agentidName">
                            <el-input v-model="queryParams.agentidName"></el-input>
                        </el-form-item>
                        <el-form-item label="筛选查询品类" prop="brand">
                            <el-select v-model="queryParams.brand" filterable>
                                <el-option v-for="item in types" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
                        </el-form-item>
                    </el-form>
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color:green;font-size: 16px;">已维护</span><span style="font-weight: bold;color: #0099ff;font-size: 16px;">—销售订单参考</span>
                    </div> 
                    <el-row :gutter="10" class="mb8">
                        <el-col :span="1.5">
                            <el-button type="success" plain icon="el-icon-download" @click="handleExport" size="mini">导出</el-button>
                        </el-col>
                    </el-row>
                    <el-table v-loading="loading" :data="linkedList" border height="500" stripe>
                        <el-table-column label="发货日期" align="center" prop="predate" />
                        <el-table-column label="大品类" align="center" prop="brand" />
                        <el-table-column label="系列" align="center" prop="xlname" />
                        <el-table-column label="产品编码" align="center" prop="pcode"/>
                        <el-table-column label="用友商品名称" align="left" width="400"  prop="pname" />
                        <el-table-column label="订单号" align="center" width="200" prop="ordercode" />
                        <el-table-column label="签单日期" align="center" prop="pubuts" />
                        <el-table-column label="片区" align="center" prop="dpt"/>
                        <el-table-column label="销售" align="center" prop="salename" />
                        <el-table-column label="客户名称" align="center" width="150" prop="agentidName" />
                        <el-table-column label="此订单需求数量" align="center" prop="subqty"/>
                    </el-table>
                    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color:red;font-size: 16px;">未维护</span><span style="font-weight: bold;color: #0099ff;font-size: 16px;">—销售订单参考</span>
                    </div> 
                    <el-row :gutter="10" class="mb8">
                        <el-col :span="1.5">
                            <el-button type="success" plain icon="el-icon-download" @click="handleExportUnLink" size="mini">导出</el-button>
                        </el-col>
                    </el-row>
                    <el-table v-loading="loading1" :data="unLinkedList" border height="500" stripe>
                        <el-table-column label="发货日期" align="center" prop="predate" />
                        <el-table-column label="大品类" align="center" prop="brand">
                            <template slot-scope="scope">
                                <span></span>
                            </template>
                        </el-table-column>
                        <el-table-column label="系列" align="center" prop="xlname">
                            <template slot-scope="scope">
                                <span></span>
                            </template>
                        </el-table-column>
                        <el-table-column label="产品编码" align="center" prop="pcode"/>
                        <el-table-column label="用友商品名称" align="left" width="400"  prop="pname" />
                        <el-table-column label="订单号" align="center" width="200" prop="ordercode" />
                        <el-table-column label="签单日期" align="center" prop="pubuts" />
                        <el-table-column label="片区" align="center" prop="dpt"/>
                        <el-table-column label="销售" align="center" prop="salename" />
                        <el-table-column label="客户名称" align="center" width="150" prop="agentidName" />
                        <el-table-column label="此订单需求数量" align="center" prop="subqty"/>
                    </el-table>
                    <pagination v-show="total1 > 0" :total="total1" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getUnLinkList" />
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">供应商预估库存不足明细表</span><span style="color:red;font-size: 12px;">（采购需补采数量=供应商预估可供量+期初现球-销售接单量）</span>
                    </div> 
                    <el-row :gutter="10" class="mb8">
                        <el-col :span="1.5">
                            <el-button type="success" plain icon="el-icon-download" size="mini" @click="exportInventory">导出</el-button>
                        </el-col>
                    </el-row>
                    <el-table v-loading="loading2" :data="inventoryList" border height="500" stripe>
                        <el-table-column label="大品类" align="center" prop="brand"></el-table-column>
                        <el-table-column label="规格2" align="center" prop="spec"></el-table-column>
                        <el-table-column label="产品编码" align="center" prop="pcode"></el-table-column>
                        <el-table-column label="用友产品名称" width="400" align="left" prop="yyname"></el-table-column>
                        <el-table-column label="采购英文名称" width="300" align="left" prop="cpEnName"></el-table-column>
                        <el-table-column label="销售订单数量" align="left" prop="sqty"></el-table-column>
                        <el-table-column label="采购需补采数量" align="left" prop="bcqty"></el-table-column>
                        <el-table-column label="供应商可提供量" align="center" prop="cgQty"></el-table-column>
                    </el-table>
                    <pagination v-show="total2 > 0" :total="total2" :page.sync="queryParams1.pageNum" :limit.sync="queryParams1.pageSize" @pagination="getInventoryList" />
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="补库存" name="second">
                <el-card class="box-card">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">筛选条件</span>
                    </div> 
                    <el-row>
                        <el-col :span="16">
                            <el-form :model="queryParams20" ref="queryForm1" size="small" :inline="true" label-width="110px" label-position="top">
                                <el-form-item label="用友商品名称" prop="yyname">
                                    <el-input v-model="queryParams20.yyname"></el-input>
                                </el-form-item>
                                <el-form-item label="大品类" prop="brand">
                                    <el-select v-model="queryParams20.brand" filterable>
                                        <el-option v-for="item in brands" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item>
                                    <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery20">搜索</el-button>
                                    <el-button icon="el-icon-refresh" size="mini" @click="resetQuery20">重置</el-button>
                                </el-form-item>
                            </el-form>
                        </el-col>
                        <el-col :span="8" v-if="cgAllList.length>0">
                            <fieldset>
                                <legend>颜色值对照</legend>
                                <table v-for="item in brandsColor" :key="item.value">
                                    <tr>
                                        <td><div style="height:20px;width: 40px;" :style="{ backgroundColor: item.color }"></div></td>
                                        <td>{{ item.value }}</td>
                                    </tr>
                                </table>
                            </fieldset>
                        </el-col>
                    </el-row>
                </el-card>
                
                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">需采购数量<span style="margin-left:10px;font-size: 12px;color: red;">[共{{ cgAllList.length }}条数据]</span></span>
                    </div> 
                    <el-table :data="cgAllList" border height="500" stripe>
                        <el-table-column label="大品类" width="150" align="center" prop="brand"></el-table-column>
                        <el-table-column label="采购英文名称" width="300" align="left" prop="cpEnName"></el-table-column>
                        <el-table-column label="产品编码" align="center" width="120" prop="pcode"></el-table-column>
                        <el-table-column label="规格2" align="center" width="100" prop="spec"></el-table-column>
                        <el-table-column label="用友产品名称" width="350" align="left" prop="yyname"></el-table-column>
                        <el-table-column align="left" prop="bcqty">
                            <template slot-scope="scope">
                                <table>
                                    <tr>
                                        <td><el-progress :stroke-width="30" :percentage="scope.row.bcqtyNum" :color="getProgressColor(scope.row.brand)" :format="format" /></td>
                                        <td><span style="font-weight: bold;">{{ scope.row.bcqty }}</span></td>
                                    </tr>
                                </table>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">需采购明细表<span style="margin-left:10px;font-size: 12px;color: red;">[共{{ cgAllList.length }}条数据]</span></span> <el-button v-if="cgAllList.length>0" style="margin-left: 10px;" type="success" plain icon="el-icon-download" size="mini" @click="exportCgAllList">导出</el-button>
                    </div> 
                    <el-table :data="cgAllList" border height="500" stripe>
                        <el-table-column label="大品类" width="150" align="center" prop="brand"></el-table-column>
                        <el-table-column label="规格2" align="center" width="100" prop="spec"></el-table-column>
                        <el-table-column label="采购英文名称" width="300" align="left" prop="cpEnName"></el-table-column>
                        <el-table-column label="产品编码" align="center" width="120" prop="pcode"></el-table-column>
                        <el-table-column label="用友产品名称" width="300" align="left" prop="yyname"></el-table-column>
                        <el-table-column label="供应商可提供数量" align="left" prop="kc">
                        </el-table-column>
                        <el-table-column label="需采购量" align="left" prop="bcqty"></el-table-column>
                    </el-table>
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">受库存不足影响订单参考<span style="margin-left:10px;font-size: 12px;color: red;">[共{{ cgAllDetailList.length }}条数据]</span></span> <el-button v-if="cgAllDetailList.length>0" style="margin-left: 10px;" type="success" plain icon="el-icon-download" size="mini" @click="exportCgAllDetailList">导出</el-button>
                    </div> 
                    <el-form :model="queryParams30" ref="queryForm3" size="small" :inline="true" label-width="110px" label-position="top">
                        <el-form-item label="发货时间-起始" prop="fhDateStart">
                            <el-date-picker v-model="queryParams30.fhDateStart" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="发货时间-结束" prop="fhDateEnd">
                            <el-date-picker v-model="queryParams30.fhDateEnd" type="date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="客户姓名" prop="agentidName">
                            <el-input v-model="queryParams30.agentidName"></el-input>
                        </el-form-item>
                        <el-form-item label="片区" prop="dpt">
                            <el-select v-model="queryParams30.dpt" filterable>
                                <el-option v-for="item in depts30" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="销售" prop="salename">
                            <el-select v-model="queryParams30.salename" filterable>
                                <el-option v-for="item in sales30" :key="item.value" :label="item.label" :value="item.value"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery30">搜索</el-button>
                            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery30">重置</el-button>
                        </el-form-item>
                    </el-form>

                    <el-table v-loading="loading" :data="cgAllDetailList" border height="500" stripe>
                        <el-table-column label="发货日期" align="center" prop="predate" />
                        <el-table-column label="大品类" align="center" prop="brand" />
                        <el-table-column label="系列" align="center" prop="xlname" />
                        <el-table-column label="产品编码" align="center" prop="pcode"/>
                        <el-table-column label="用友商品名称" align="left" width="400"  prop="pname" />
                        <el-table-column label="订单号" align="center" width="200" prop="ordercode" />
                        <el-table-column label="签单日期" align="center" prop="pubuts" />
                        <el-table-column label="片区" align="center" prop="dpt"/>
                        <el-table-column label="销售" align="center" prop="salename" />
                        <el-table-column label="客户名称" align="center" width="150" prop="agentidName" />
                        <el-table-column label="此订单需求数量" align="center" prop="subqty"/>
                    </el-table>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="去库存" name="third">
                <el-card class="box-card">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">筛选条件</span>
                    </div> 
                    <el-col :span="16">
                        <el-form :model="queryParams40" ref="queryForm4" size="small" :inline="true" label-width="110px" label-position="top">
                            <el-form-item label="用友商品名称" prop="yyname">
                                <el-input v-model="queryParams40.yyname"></el-input>
                            </el-form-item>
                            <el-form-item label="大品类" prop="brand">
                                <el-select v-model="queryParams40.brand" filterable>
                                    <el-option v-for="item in brands40" :key="item.value" :label="item.label" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item>
                                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery40">搜索</el-button>
                                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery40">重置</el-button>
                            </el-form-item>
                        </el-form>
                    </el-col>
                    <el-col :span="8" v-if="acceptList.length>0">
                        <fieldset>
                            <legend>颜色值对照</legend>
                            <table v-for="item in brandsColor1" :key="item.value">
                                <tr>
                                    <td><div style="height:20px;width: 40px;" :style="{ backgroundColor: item.color }"></div></td>
                                    <td>{{ item.value }}</td>
                                </tr>
                            </table>
                        </fieldset>
                    </el-col>
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">剩余可接单量<span style="margin-left:10px;font-size: 12px;color: red;">[共{{ acceptList.length }}条数据]</span></span>
                    </div> 
                    <el-table :data="acceptList" border height="500" stripe>
                        <el-table-column label="大品类" width="150" align="center" prop="brand"></el-table-column>
                        <el-table-column label="产品编码" align="center" width="120" prop="pcode"></el-table-column>
                        <el-table-column label="规格2" align="center" width="100" prop="spec"></el-table-column>
                        <el-table-column label="用友产品名称" width="350" align="left" prop="yyname"></el-table-column>
                        <el-table-column label="采购英文名称" width="300" align="left" prop="cpEnName"></el-table-column>
                        <el-table-column align="left" prop="bcqty">
                            <template slot-scope="scope">
                                <table>
                                    <tr>
                                        <td><el-progress :stroke-width="30" :percentage="scope.row.bcqtyNum" :color="getProgressColor1(scope.row.brand)" :format="format" /></td>
                                        <td><span style="font-weight: bold;">{{ scope.row.bcqty }}</span></td>
                                    </tr>
                                </table>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-card>

                <el-card class="box-card" style="margin-top: 10px;">
                    <div slot="header" class="clearfix">
                        <span style="font-weight: bold;color: #0099ff;font-size: 16px;">剩余可接单量库存明细表<span style="font-size: 14px;color:orange">（剩余可接单量=供应商预估可供量+期初现球-销售接单量）</span><span style="margin-left:10px;font-size: 12px;color: red;">[共{{ acceptList.length }}条数据]</span></span><el-button v-if="acceptList.length>0" style="margin-left: 10px;" type="success" plain icon="el-icon-download" size="mini" @click="exportAccept">导出</el-button>
                    </div> 
                    <el-table :data="acceptList" border height="500" stripe>
                        <el-table-column label="规格2" align="center" width="100" prop="spec"></el-table-column>
                        <el-table-column label="大品类" width="150" align="center" prop="brand"></el-table-column>
                        <el-table-column label="采购英文名称" width="300" align="left" prop="cpEnName"></el-table-column>
                        <el-table-column label="产品编码" align="center" width="120" prop="pcode"></el-table-column>
                        <el-table-column label="用友产品名称" width="300" align="left" prop="yyname"></el-table-column>
                        <el-table-column label="供应商可提供数量" align="left" prop="cgQty"></el-table-column>
                        <el-table-column label="销售订单量" align="left" prop="sqty"></el-table-column>
                        <el-table-column label="剩余可接单量" align="left" prop="bcqty"></el-table-column>
                    </el-table>
                </el-card>
            </el-tab-pane>
        </el-tabs>
    </div>
  </template>
  <script>
   import { getInitParams,listLinked,listUnLinked,getInventoryList,getBrandsList,listCgAll,getInitParams30,getZqDetailList,getBrandsListAccept,listAcceptList } from "@/api/system/cg/cgimport";
  export default {
    name: "Cgplddhz",
    data() {
      return {
        loading: true,
        loading1: true,
        loading2: true,
        total: 0,
        total1: 0,
        total2: 0,
        activeName: 'first',
        queryParams20: {
            pageNum: 1,
            pageSize: 10,
            yyname: null,
            brand:null,
        },
        queryParams1: {
            pageNum: 1,
            pageSize: 10,
        },
        queryParams30: {
            fhDateStart: null,
            fhDateEnd: null,
            dpt: null,
            salename:null,
            agentidName: null,
        },
        queryParams40: {
            yyname: null,
            brand:null,
        },
        queryParams: {
            pageNum: 1,
            pageSize: 10,
            fhDateStart: null,
            fhDateEnd: null,
            pname: null,
            dpt: null,
            salename:null,
            agentidName: null,
            brand:null,
        },
        depts:[],
        sales:[],
        types:[],
        linkedList:[],
        unLinkedList:[],
        inventoryList:[],
        brands:[],
        brands40:[],
        brandsColor:[],
        brandsColor1:[],
        cgAllList:[],
        cgAllDetailList:[],
        depts30:[],
        sales30:[],
        acceptList:[],
      };
    },
    created() {
        this.queryParams.fhDateStart = "2025-01-01";
        this.queryParams.fhDateEnd = "2025-12-31";
        this.getInitParams();
        this.queryParams.dpt = "all";
        this.queryParams.salename = "all";
        this.queryParams.brand = "all";
        this.getList();
        this.getUnLinkList();
        this.getInventoryList();
    },
    methods: {
        getProgressColor(brand){
            let brandStr = "";
            if(brand=="null"||brand==null){
                brandStr = "Null";
            }else{
                brandStr = brand;
            }
            for(let i=0;i<this.brandsColor.length;i++){
                if(this.brandsColor[i].value==brandStr){
                    return this.brandsColor[i].color;
                }
            }
        },
        getProgressColor1(brand){
            let brandStr = "";
            if(brand=="null"||brand==null){
                brandStr = "Null";
            }else{
                brandStr = brand;
            }
            for(let i=0;i<this.brandsColor1.length;i++){
                if(this.brandsColor1[i].value==brandStr){
                    return this.brandsColor1[i].color;
                }
            }
        },
        format(percentage) {
            return '';
        },
        exportInventory(){
            this.download('system/importcg/exportInventory', {
                ...this.queryParams1
            }, `供应商预估库存不足明细表_${new Date().getTime()}.xlsx`)
        },
        handleExportUnLink(){
            this.download('system/importcg/exportUnLinked', {
                ...this.queryParams
            }, `未维护—销售订单参考_${new Date().getTime()}.xlsx`)
        },
        handleExport() {
            this.download('system/importcg/exportLinked', {
                ...this.queryParams
            }, `已维护—销售订单参考_${new Date().getTime()}.xlsx`)
        },
        exportCgAllList() {
            this.download('system/importcg/exportCgAllList', {
                ...this.queryParams20
            }, `需采购数量_${new Date().getTime()}.xlsx`)
        },
        exportCgAllDetailList(){
            this.download('system/importcg/exportCgAllDetailList', {
                ...this.queryParams30
            }, `受库存不足影响订单_${new Date().getTime()}.xlsx`)
        },
        exportAccept(){
            this.download('system/importcg/exportAccept', {
                ...this.queryParams30
            }, `剩余可接单量库存明细_${new Date().getTime()}.xlsx`)
        },
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
            this.getUnLinkList();
        },
        handleQuery30() {
            this.getZqList();
        },
        handleQuery20() {
            this.listCgAll();
        },
        handleQuery40() {
            this.listAcceptList();
        },
        listCgAll(){
            listCgAll(this.queryParams20).then(res =>{
                this.cgAllList = res.data;
            })  
        },
        getInventoryList(){
            this.loading2 = true;
            getInventoryList(this.queryParams1).then(res => {
                this.inventoryList = res.rows;
                this.total2 = res.total;
                this.loading2 = false;
            })
        },
        getUnLinkList(){
            this.loading1 = true;
            if(this.queryParams.fhDateStart!=null&&this.queryParams.fhDateEnd!=null){
                listUnLinked(this.queryParams).then(response => {
                    this.unLinkedList = response.rows;
                    this.total1 = response.total;
                    this.loading1 = false;
                    }
                );
            }else{
                this.$message.error("设置查询时间");
            }
        },
        getList() {
            this.loading = true;
            if(this.queryParams.fhDateStart!=null&&this.queryParams.fhDateEnd!=null){
                listLinked(this.queryParams).then(response => {
                    this.linkedList = response.rows;
                    this.total = response.total;
                    this.loading = false;
                    }
                );
            }else{
                this.$message.error("设置查询时间");
            }
        },
        getZqList(){
            getZqDetailList(this.queryParams30).then(res =>{
                this.cgAllDetailList = res.data;
            })
        },
        getInitParams(){
            getInitParams().then(res =>{
                if(res.code===200){
                    this.depts = res.data.depts;
                    this.sales = res.data.sales;
                    this.types = res.data.types;
                }
            })
        },
        getInitParams30(){
            getInitParams30().then(res =>{
                this.depts30 = res.data.depts;
                this.sales30 = res.data.sales;
            })
        },
        handleClick(tab, event) {
            if(tab.index==1){
                this.brandsColor = [];
                this.queryParams20.brand = "all";
                this.queryParams20.yyname = null;
                getBrandsList().then(res =>{
                    if(res.code===200){
                        this.brands = res.data;
                        if(res.data.length>0){
                            for(let i=0;i<res.data.length;i++){
                                if(res.data[i].value!="all"){
                                    const randomHex = Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')
                                    let colorData = {
                                        value:res.data[i].value,
                                        color:"#"+randomHex
                                    }
                                    this.brandsColor.push(colorData)
                                }
                            }
                        }
                    }else{
                        this.brands = [];
                        this.queryParams20.brand = null;
                    }
                }) 
                this.cgAllList = []; 
                listCgAll(this.queryParams20).then(res =>{
                    this.cgAllList = res.data;
                })
                this.queryParams30.fhDateStart = "2025-01-01";
                this.queryParams30.fhDateEnd = "2025-12-31";
                this.queryParams30.agentidName = null;
                this.getInitParams30();
                this.queryParams30.dpt = "all";
                this.queryParams30.salename = "all";    
                this.getZqList();
            }else if(tab.index==2){
                this.brandsColor1 = [];
                this.queryParams40.brand = "all";
                this.queryParams40.yyname = null;
                getBrandsListAccept().then(res =>{
                    if(res.code===200){
                        this.brands40 = res.data;
                        if(res.data.length>0){
                            for(let i=0;i<res.data.length;i++){
                                if(res.data[i].value!="all"){
                                    const randomHex = Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')
                                    let colorData = {
                                        value:res.data[i].value,
                                        color:"#"+randomHex
                                    }
                                    this.brandsColor1.push(colorData)
                                }
                            }
                        }
                    }else{
                        this.brands = [];
                        this.queryParams40.brand = null;
                    }
                }) 
                this.acceptList = [];
                this.listAcceptList();
            }
        },
        listAcceptList(){
            listAcceptList(this.queryParams40).then(res =>{
                this.acceptList = res.data;
            })
        },
        resetQuery(){
            this.queryParams.dpt = "all";
            this.queryParams.salename = "all";
            this.queryParams.brand = "all";
            this.resetForm("queryForm");
            this.handleQuery();
        },
        resetQuery20(){
            this.brandsColor = [];
            getBrandsList().then(res =>{
                if(res.code===200){
                    this.brands = res.data;
                    this.queryParams20.brand = "all";
                    if(res.data.length>0){
                        for(let i=0;i<res.data.length;i++){
                            if(res.data[i].value!="all"){
                                const randomHex = Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')
                                let colorData = {
                                    value:res.data[i].value,
                                    color:"#"+randomHex
                                }
                                this.brandsColor.push(colorData)
                            }
                        }
                    }
                }else{
                    this.brands = [];
                    this.queryParams20.brand = null;
                }
            }) 
            this.queryParams20.yyname = null;
            this.resetForm("queryForm1");
            this.handleQuery20();
        },
        resetQuery30(){    
            this.resetForm("queryForm3");
            this.queryParams30.fhDateStart = "2025-01-01";
            this.queryParams30.fhDateEnd = "2025-12-31";
            this.queryParams30.agentidName = null;
            this.queryParams30.dpt = "all";
            this.queryParams30.salename = "all";
            this.handleQuery30();
        },
        resetQuery40(){ 
            this.brandsColor1 = [];
            getBrandsListAccept().then(res =>{
                if(res.code===200){
                    this.brands40 = res.data;
                    if(res.data.length>0){
                        for(let i=0;i<res.data.length;i++){
                            if(res.data[i].value!="all"){
                                const randomHex = Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0')
                                let colorData = {
                                    value:res.data[i].value,
                                    color:"#"+randomHex
                                }
                                this.brandsColor1.push(colorData)
                            }
                        }
                    }
                }else{
                    this.brands = [];
                    this.queryParams40.brand = null;
                }
            }) 
            this.queryParams40.yyname = null;
            this.resetForm("queryForm4");
            this.handleQuery40();
        },
    }
  };
  </script>
  <style scoped>
  ::v-deep .el-progress-bar__outer {
      background-color: transparent; 
      border-radius: 0; /* 移除底色圆角 */
  }
::v-deep .el-progress-bar {
  width: 500px; /* 设置长方形宽度 */
  height: 40px; /* 设置长方形高度 */
}

::v-deep .el-progress-bar__inner {
  height: 100%; /* 填充整个高度 */
  border-radius: 0 !important;  /* 移除圆角，使其变为方形 */
}

::v-deep .el-progress-bar__innerText {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 20px;
color: #ee0505;
}
</style>